package xyz.chaobei.thread.callback;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * @copyright (C), 2015-2020
 * @fileName: Main
 * @author: MRC
 * @date: 2021/1/28 22:39
 * @description:
 */
@Slf4j
public class Main {

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ExecutorService service = Executors.newCachedThreadPool();

        Callable<String> task = new Task();

        log.info("submit");
        Future<String> result = service.submit(task);

        log.info("get");
        // get 方法会阻塞当前线程，直到返回结果
        String desc = result.get();
        log.info("desc={}",desc);
    }

}
